package org.wlldTest.lesson1;

import java.util.Random;

public class PreBody {//y=wx-b
    private double w;
    private double b;
    private double x;
    private double y;
    private double studyPad = 0.0005;

    public PreBody() {
        Random random = new Random();
        w = random.nextDouble();
        b = random.nextDouble();
    }

    public double insertParameter(double parameter) {//运算参数
        y = w * parameter - b;
        this.x = parameter;
        return y;
    }

    public void backError(double E) {
        double error = (E - y) * studyPad;
        double subW = error * this.x;//w的误差值
        double subB = -error;
        w = w + subW;
        b = b + subB;
    }
}
